package com.woniu.project.service.impl;


import com.woniu.project.core.domain.ProductEntityPropertyCentre;
import com.woniu.project.dao.ProductEntityPropertyCentreMapper;
import com.woniu.project.service.IProductEntityPropertyCentreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author WHF
 * @since 2020-10-13
 */
@Service
public class ProductEntityPropertyCentreServiceImpl extends ServiceImpl<ProductEntityPropertyCentreMapper, ProductEntityPropertyCentre> implements IProductEntityPropertyCentreService {

    @Autowired
    private ProductEntityPropertyCentreMapper productEntityPropertyCentreMapper;

    /**
     * 根据商品实体id删除对应属性关系
     * @param productEntityId 商品实体id
     */
    @Override
    public void deleteByProductEntityId(Integer productEntityId) {

        productEntityPropertyCentreMapper.deleteByProductEntityId(productEntityId);
    }

    /**
     *新增商品实体属性和属性值对应关系
     * @param productEntityId
     * @param productPropertyId
     * @param productPropertyValueId
     */
    @Override
    public void insertPropertyCentre(Integer productEntityId, Integer productPropertyId, Integer productPropertyValueId) {
        ProductEntityPropertyCentre productEntityPropertyCentre=new ProductEntityPropertyCentre();
        productEntityPropertyCentre.setProductEntityId(productEntityId);
        productEntityPropertyCentre.setProductPropertyId(productPropertyId);
        productEntityPropertyCentre.setProductPropertyValueId(productPropertyValueId);
        productEntityPropertyCentreMapper.insert(productEntityPropertyCentre);
    }
}
